#include <cstdio>
#include <algorithm>
using namespace std;

int x, y;

int main()
{
	scanf("%d%d", &x, &y);
	printf("%d\n", __gcd(x, y));
}
